home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMCAFExa.lha / AMCAF_Examples / Banks.AMOS / Banks.amosSourceCode
Encoding:
AMOS Source Code  |  1996-01-17  |  5.6 KB  |  213 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Bank Permanent     Bank Name 
  3. ' *           Amcaf Examples          * Bank Temporary     =Bank Name$ 
  4. ' *     Bank Commands Part 1 V1.0     * Bank To Fast 
  5. ' *      Written by Chris Hodges      * Bank To Chip 
  6. ' *                                   * Bank Stretch 
  7. ' ************************************* Bank Copy
  8. '                          
  9. Gosub INITSCREEN
  10. Gosub RESERVEBANKS
  11. Gosub EXBANKSTRETCH
  12. Gosub EXBANKTOCHIP
  13. TEXSCROLL[21]
  14. Gosub EXBANKTOFAST
  15. Gosub EXBANKNAME
  16. TEXSCROLL[20]
  17. Gosub EXBANKNAMESTR
  18. Gosub EXBANKPERMANENT
  19. TEXSCROLL[22]
  20. Gosub EXBANKTEMPORARY
  21. Gosub EXBANKCOPY
  22. TEXSCROLL[23]
  23. Gosub THEEND
  24. End 
  25.  
  26. ' Open a cute little screen
  27. INITSCREEN:
  28.   Screen Open 0,640,256,2,Hires
  29.   Palette 0,$FFF
  30.   Curs Off 
  31.   ' Give out a smart title 
  32.   Centre "Bank Commands Example Part 1 V1.0" : Print : Print 
  33. Return 
  34.  
  35. ' Some short comments... 
  36. THEEND:
  37.   Print "This is the end of part 1 in banks examples."
  38.   Print "I hope you now understand what these commands do and how you can use them."
  39.   Print 
  40.   Print "CU at the next part..."
  41.   KEY
  42. Return 
  43.  
  44. ' First let's reserve some banks 
  45. RESERVEBANKS:
  46.   Reserve As Work 10,1024 : Rem Reserves a fastmem 1 KB temporary bank 
  47.   Reserve As Chip Work 11,2048 : Rem Reserves a chipmem 2 KB temporary bank 
  48.   Reserve As Data 12,4096 : Rem Reserves a fastmem 4 KB permanent bank 
  49.   Reserve As Chip Data 13,8192 : Rem Reserves a chipmem 8 KB permanent bank 
  50.   List Bank 
  51.   Print 
  52.   Print "These are some banks created using 'Reserve As...'"
  53.   Print 
  54.   KEY
  55. Return 
  56.  
  57. ' Command: Bank Stretch
  58. EXBANKSTRETCH:
  59.   Print "Now let's alter one bank... I think bank 10 is not large enough for my usage"
  60.   Print "so I enlarge it using 'Bank Stretch' to my benefits."
  61.   Print 
  62.   KEY
  63.   ' Note the synopsis: Bank Stretch BANK To NEWSIZE
  64.    Extension_8_0244 10 To 10240
  65.   List Bank 
  66.   Print 
  67.   Print "Compare... and note that the address has changed!"
  68.   Print "The new size may be also smaller, having the same effect as 'Bank Shrink'."
  69.   Print 
  70.   KEY
  71. Return 
  72.  
  73. ' Command: Bank To Chip  
  74. EXBANKTOCHIP:
  75.   Print "I decide to put bank 12 into chipmem, because it's holding some kind of sound."
  76.   Print "So I use 'Bank To Chip' to move it into chipmem."
  77.   Print 
  78.   KEY
  79.   ' Note the synopsis: Bank To Chip BANK 
  80.    Extension_8_00A0 12
  81.   List Bank 
  82.   Print 
  83.   Print "The bank is now in chipmem at address ";Hex$(Start(12),6);"."
  84.   Print 
  85.   KEY
  86. Return 
  87.  
  88. ' Command: Bank To Fast
  89. EXBANKTOFAST:
  90.   Print "Bank 13 holds another sound, but it is currently not used, so I move it into"
  91.   Print "fastmem to get some more chipmem."
  92.   Print 
  93.   KEY
  94.   ' Synopsis same as 'Bank To Chip': Bank To Fast BANK 
  95.    Extension_8_00B4 13
  96.   List Bank 
  97.   Print 
  98.   Print "The bank is now in fastmem."
  99.   Print 
  100.   KEY
  101. Return 
  102.  
  103. ' Command: Bank Name 
  104. EXBANKNAME:
  105.   Print "Don't you think 'Data' sounds a bit boring? What about 'Mr. Data' (TNG rulez!)?"
  106.   Print "I'll try it with bank 12 again using 'Bank Name'."
  107.   Print 
  108.   KEY
  109.   ' Note the synopsis: Bank Name BANK,NAME$
  110.    Extension_8_028C 12,"Mr. Data"
  111.   List Bank 
  112.   Print 
  113.   Print "Look! There he is! :-)"
  114.   Print 
  115.   KEY
  116. Return 
  117.  
  118. ' Function: =Bank Name$
  119. EXBANKNAMESTR:
  120.   Print "Certainly, you can get the current name of a bank using the function"
  121.   Print "'=Bank Name$'. I'll rename bank 10 and read it out afterwards."
  122.   Print 
  123.   KEY
  124.    Extension_8_028C 10,"Megacool"
  125.   List Bank 
  126.   Print 
  127.   ' Synopsis: NAME$=Bank Name$(BANK) 
  128.   Print "The new name of bank 10 is '"; Extension_8_027A(10);"'."
  129.   Print 
  130.   KEY
  131. Return 
  132.  
  133. ' Command: Bank Permanent
  134. EXBANKPERMANENT:
  135.   Print "'I would never let you go...', I said to bank 11, which is currently"
  136.   Print "a temporary bank and would be erased on the start of the program."
  137.   Print "So what can you do, if you want a temporary bank to become a permantent one?"
  138.   Print "I use 'Bank Permanent' on bank 11 and then call 'Erase Temp'."
  139.   Print 
  140.   KEY
  141.   ' Synopsis: Bank Permanent BANK
  142.    Extension_8_0074 11
  143.   Erase Temp 
  144.   List Bank 
  145.   Print 
  146.   Print "Look what happended! Bank 11 stayed, but Bank 10 has been erased (sniff)."
  147.   Print 
  148.   KEY
  149. Return 
  150.  
  151. ' Command: Bank Temporary
  152. EXBANKTEMPORARY:
  153.   Print "'Bank 13, I'm sorry, but I don't want you to stay in my program. By the"
  154.   Print "next 'Erase Temp' you'll have to go'..."
  155.   Print "And so I use 'Bank Temporary', which does the opposite of 'Bank Permanent'."
  156.   Print 
  157.   KEY
  158.   ' Synopsis like 'Bank Permanent': Bank Temporary BANK
  159.    Extension_8_008A 13
  160.   Erase Temp 
  161.   List Bank 
  162.   Print 
  163.   Print "Only two banks left, hu?"
  164.   Print 
  165.   KEY
  166. Return 
  167.  
  168. ' Command: Bank Copy 
  169. EXBANKCOPY:
  170.   Print "Bank 12 seems so alone, let's clone him using 'Bank Copy'!!!"
  171.   Print 
  172.   KEY
  173.   ' Synopsis: Bank Copy SOURCEBANK To TARGETBANK 
  174.   '           Bank Copy STARTADDRESS,ENDADDRESS To TARGETBANK
  175.    Extension_8_025A 12 To 10
  176.   List Bank 
  177.   Print 
  178.   Print "Look! Now we've got another Mr. Data in bank 10!"
  179.   Print 
  180.   KEY
  181. Return 
  182.  
  183. ' This is to move some text upwards
  184. Procedure TEXSCROLL[LINES]
  185.   ' Get old cursor position  
  186.   Y=Y Curs
  187.   ' Set up scrollzone
  188.   Def Scroll 1,0,18 To 640,248,0,-2
  189.   ' Now scroll this zone up serveral times 
  190.   For A=1 To LINES*4
  191.     ' Syncronize, but be system friendly 
  192.     Multi Wait 
  193.     ' Scroll up  
  194.     Scroll 1
  195.   Next 
  196.   ' Now move up cursor 
  197.   Locate ,Y-LINES
  198. End Proc
  199. ' This small procedure waits for an keypress.  
  200. Procedure KEY
  201.   ' Save the cursors original position 
  202.   Memorize X : Memorize Y 
  203.   ' Prompt some text at the bottom.
  204.   Locate 0,31 : Centre "Press any key to continue."
  205.   ' I do not use 'Wait Key', because it's not multitasking friendly  
  206.   Repeat 
  207.     Multi Wait 
  208.   Until Inkey$<>""
  209.   ' Clear the line 
  210.   Cline 
  211.   ' Restore the position 
  212.   Remember X : Remember Y 
  213. End Proc